import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/home', // 这里随便写，写什么就输入什么路径，用于地址栏显示
    name: 'home',
    component: () => import('../views/home/motherPage.vue'), // 这里才是真正的真实地址，必须写对
    redirect: '/home/user', // 进来就重定向
    children: [ // 二级路由
      {
        path: '/home/user',
        name: 'user',
        component: () => import('../views/home/child/userPage.vue')
      },
      {
        path: '/home/source',
        name: 'source',
        component: () => import('../views/home/child/sourcePage.vue')
      },
      {
        path: '/home/rights',
        name: 'rights',
        component: () => import('../views/home/child/rightsPage.vue')
      },
      {
        path: '/home/finance',
        name: 'finance',
        component: () => import('../views/home/child/financePage.vue')
      }
    ]
  },
  {
    path: '/register',
    name: 'register',
    component: () => import('../views/registerPage.vue')
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('../views/loginPage.vue')
  },
  {
    path: '*',
    name: 'notFound',
    component: () => import('../views/notFound.vue')
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
